﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Zero.UControl.Base.Models
{
    public class CascaderItem : INotifyPropertyChanged
    {
        #region 普通属性
        private string label;

        public string Label
        {
            get { return label; }
            set
            {
                label = value;
                OnPropertyChanged(nameof(Label));
            }
        }

        private string value;

        public string Value
        {
            get { return value; }
            set
            {
                this.value = value;
                OnPropertyChanged(nameof(Value));
            }
        }

        private bool isChecked;

        public bool IsChecked
        {
            get { return isChecked; }
            set
            {
                isChecked = value;
                OnPropertyChanged(nameof(IsChecked));
            }
        }

        private bool isExpanded;

        public bool IsExpanded
        {
            get { return isExpanded; }
            set
            {
                isExpanded = value;
                OnPropertyChanged(nameof(IsExpanded));
            }
        }

        private bool isDisabled;

        public bool IsDisabled
        {
            get { return isDisabled; }
            set
            {
                isDisabled = value;
                OnPropertyChanged(nameof(IsExpanded));
            }
        }

        private CascaderItem parent;

        public CascaderItem Parent
        {
            get { return parent; }
            set
            {
                parent = value;
                OnPropertyChanged(nameof(Parent));
            }
        }

        private bool isMultiSelect = false;

        public bool IsMultiSelect
        {
            get { return isMultiSelect; }
            set
            {
                isMultiSelect = value;
                OnPropertyChanged(nameof(IsMultiSelect));
            }
        }

        public bool HasChildren => Children.Count != 0;


        public string FullPath => Parent == null ? Label : $"{Parent.FullPath} / {Label}";

        public ObservableCollection<CascaderItem> Children { get; set; } = new();
        #endregion

        public event PropertyChangedEventHandler PropertyChanged;
        protected void OnPropertyChanged(string prop) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(prop));
    }
}
